home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 1.iso / toolbox / src / exampleCode / opengl / XLayerInfo / xlayerinfo.c < prev    next >
C/C++ Source or Header  |  1996-11-11  |  3KB  |  88 lines

  1. /*
  2.  * Copyright (c) 1993-94, Silicon Graphics, Inc.
  3.  *
  4.  * Permission to use, copy, modify, distribute, and sell this software and
  5.  * its documentation for any purpose is hereby granted without fee, provided
  6.  * that the name of Silicon Graphics may not be used in any advertising or
  7.  * publicity relating to the software without the specific, prior written
  8.  * permission of Silicon Graphics.
  9.  *
  10.  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND,
  11.  * EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY
  12.  * WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
  13.  *
  14.  * IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, INCIDENTAL,
  15.  * INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER
  16.  * RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE
  17.  * POSSIBILITY OF DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN
  18.  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  19.  *
  20.  * OpenGL(TM) is a trademark of Silicon Graphics, Inc.
  21.  */
  22. /* $Revision: 1.2 $ */
  23. /* compile: cc -o xlayerinfo xlayerinfo.c XLayerUtil.c -lX11 */
  24.  
  25. #include <stdio.h>
  26. #include "XLayerUtil.h"
  27.  
  28. main(argc, argv)
  29. int argc;
  30. char *argv[];
  31. {
  32.    Display *dpy;
  33.    char *display_name, *arg, *class;
  34.    XLayerVisualInfo template, *lvinfo;
  35.    int nVisuals, i;
  36.  
  37.    display_name = NULL;
  38.    for(i=1; i<argc; i++) {
  39.       arg = argv[i];
  40.       if(strcmp(arg, "-display") == 0 || strcmp(arg, "-d") == 0) {
  41.      if(++i >= argc) {
  42.         fprintf(stderr, "nmbxdemo: missing argument to -display\n");
  43.         exit(1);
  44.          }
  45.      display_name = argv[i];
  46.       }
  47.    }
  48.    dpy = XOpenDisplay(display_name);
  49.    if(dpy == NULL) {
  50.       fprintf(stderr, "xlayerinfo: cannot open display %s\n",
  51.      XDisplayName(NULL));
  52.       exit(1);
  53.    }
  54.    lvinfo = XGetLayerVisualInfo(dpy, 0L, &template, &nVisuals);
  55.    for(i=0; i<nVisuals; i++) {
  56.       printf("  Visual ID: 0x%x\n", lvinfo[i].vinfo.visualid);
  57.       printf("    screen: %d\n", lvinfo[i].vinfo.screen);
  58.       printf("    depth: %d\n", lvinfo[i].vinfo.depth);
  59.       switch(lvinfo[i].vinfo.class) {
  60.      case StaticGray:   class = "StaticGray"; break;
  61.      case GrayScale:    class = "GrayScale"; break;
  62.      case StaticColor:  class = "StaticColor"; break;
  63.      case PseudoColor:  class = "PseudoColor"; break;
  64.      case TrueColor:    class = "TrueColor"; break;
  65.      case DirectColor:  class = "DirectColor"; break;
  66.      default:           class = "Unknown"; break;
  67.       }
  68.       printf("    class: %s\n", class);
  69.       switch(lvinfo[i].type) {
  70.       case None:
  71.          printf("    transparent type: None\n");
  72.          break;
  73.       case TransparentPixel:
  74.          printf("    transparent type: TransparentPixel\n");
  75.          printf("    pixel value: %d\n", lvinfo[i].value);
  76.      break;
  77.       case TransparentMask:
  78.          printf("    transparent type: TransparentMask\n");
  79.          printf("    transparency mask: %0x%x\n", lvinfo[i].value);
  80.      break;
  81.       default:
  82.          printf("    transparent type: Unkown or invalid\n");
  83.      break;
  84.       }
  85.       printf("    layer: %d\n", lvinfo[i].layer);
  86.    }
  87. }
  88.